Fixes for tpo, an1, gpsutil, igc.
authorrobertlipe@gmail.com <robertlipe@gmail.com@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Wed, 1 Jan 2014 05:02:52 +0000 (05:02 +0000)
committerrobertlipe@gmail.com <robertlipe@gmail.com@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Wed, 1 Jan 2014 05:02:52 +0000 (05:02 +0000)
git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4693 f51c46e8-681c-474f-0cfe-069cfd0219fb

gpsbabel/an1.cc
gpsbabel/gpsutil.cc
gpsbabel/igc.cc
gpsbabel/tpo.cc

index 2e148fa8f4470886886847df53a3e6df284aaa19..9b1ab678bf643c0749537982b70a3df70fb45999 100644 (file)
@@ -707,8 +707,8 @@ static void Read_AN1_Waypoints(gbfile* f)
     }
     wpt_tmp->longitude = -DecodeOrd(rec->lon);
     wpt_tmp->latitude = DecodeOrd(rec->lat);
-    wpt_tmp->notes = xstrdup(rec->comment);
-    wpt_tmp->description = xstrdup(rec->name);
+    wpt_tmp->notes = rec->comment;
+    wpt_tmp->description = rec->name;
     if (rec->url) {
       wpt_tmp->AddUrlLink(rec->url);
 #if NEW_STRINGS
index ea60883b014f10b2dde0d7e2cb8f8edb1e94e3b7..92042666067b341adeded79d1913397094ba08b0 100644 (file)
@@ -113,6 +113,7 @@ data_read(void)
     wpt_tmp = waypt_new();
     wpt_tmp->altitude = alt;
     wpt_tmp->shortname = sn;
+    xfree(sn);
     wpt_tmp->description = desc;
     wpt_tmp->SetCreationTime(now);
 
index b0f2409d968f632a9b8b4649b15284255a74884c..6c1f3a541c21711e0773f2f3e29bea1c3ef0bfc1 100644 (file)
@@ -184,9 +184,9 @@ static void igc_task_rec(const char* rec)
 
     // Create a route to store the task data in.
     rte_head = route_head_alloc();
-    rte_head->rte_name = xstrdup(task_num);
+    rte_head->rte_name = task_num;
     sprintf(tmp_str, DATEMAGIC "%s: %s", flight_date, task_desc);
-    rte_head->rte_desc = xstrdup(tmp_str);
+    rte_head->rte_desc = tmp_str;
     route_add_head(rte_head);
     state++;
     return;
@@ -207,7 +207,7 @@ static void igc_task_rec(const char* rec)
                    (lon_deg + (lon_min * 1000 + lon_frac) / 1000.0 / 60);
 
   wpt->SetCreationTime(creation);
-  wpt->description = xstrdup(tmp_str);
+  wpt->description = tmp_str;
 
   // Name the waypoint according to the order of the task record
   switch (state) {
@@ -249,7 +249,7 @@ static void igc_task_rec(const char* rec)
     waypt_free(wpt);
     return;
   }
-  wpt->shortname = xstrdup(short_name);
+  wpt->shortname = short_name;
   route_add_wpt(rte_head, wpt);
 }
 
@@ -331,15 +331,15 @@ static void data_read(void)
       // Create a track for pressure altitude waypoints
       if (!pres_head) {
         pres_head = route_head_alloc();
-        pres_head->rte_name = xstrdup(PRESTRKNAME);
-        pres_head->rte_desc = xstrdup(trk_desc);
+        pres_head->rte_name = PRESTRKNAME;
+        pres_head->rte_desc = trk_desc;
         track_add_head(pres_head);
       }
       // Create a second track for GNSS altitude waypoints
       if (!gnss_head) {
         gnss_head = route_head_alloc();
-        gnss_head->rte_name = xstrdup(GNSSTRKNAME);
-        gnss_head->rte_desc = xstrdup(trk_desc);
+        gnss_head->rte_name = GNSSTRKNAME;
+        gnss_head->rte_desc = trk_desc;
         track_add_head(gnss_head);
       }
       // Create a waypoint from the fix record data
@@ -630,7 +630,7 @@ static void wr_header(void)
 // is a c string that's used for totally too many things.  Just let it
 // leak for now. 2013-12-31 robertl
     if (NULL != (wpt = find_waypt_by_name("PILOT")) && !wpt->description.isEmpty()) {
-      str = xstrdup(CSTRc(wpt->description));
+      str = CSTRc(wpt->description);
 #else
     if (NULL != (wpt = find_waypt_by_name("PILOT")) && wpt->description) {
       str = CSTRc(wpt->description);
index 36ef3657a3c8d8a906baa82a443a500a8663c524..2b382800129c4de2976ce04e28a7ce06625b20ac 100644 (file)
@@ -281,7 +281,7 @@ void tpo_read_2_x(void)
 
     /* generate a generic track name */
     sprintf(buff, "Track %d", i+1);
-    track_temp->rte_name = xstrdup(buff);
+    track_temp->rte_name = buff;
 
     /* zoom level 1-5 visibility flags */
     gbfread(&buff[0], 1, 10, tpo_file_in);
@@ -656,6 +656,7 @@ void tpo_process_tracks(void)
       xasprintf(&track_name, "TRK %d", ii+1);
     }
     track_temp->rte_name = track_name;
+    xfree(track_name);
 
     // RGB line_color expressed for html=rrggbb and kml=bbggrr - not assigned before 2012
     sprintf(rgb,"%02x%02x%02x",styles[track_style].color[0],styles[track_style].color[1],styles[track_style].color[2]);
@@ -884,6 +885,7 @@ void tpo_process_waypoints(void)
 
     // Assign the waypoint name
     waypoint_temp->shortname = waypoint_name;
+    xfree(waypoint_name);
 
     // Grab the altitude in meters
     altitude = gbfgetint32(tpo_file_in);
@@ -905,9 +907,7 @@ void tpo_process_waypoints(void)
       gbfread(comment, 1, name_length, tpo_file_in);
       comment[name_length] = '\0';  // Terminator
       waypoint_temp->description = comment;
-//printf("\tComment: %s\n", waypoint_name);
-    } else {
-//            waypoint_temp->description = NULL;
+      xfree(comment);
     }
 
 //        waypoint_temp->notes = NULL;
@@ -1110,7 +1110,6 @@ void tpo_process_symbols(void)
   for (ii = 0; ii < waypoint_count; ii++) {
     int lat;
     int lon;
-    char* waypoint_name;
     waypoint* waypoint_temp;
 
 
@@ -1127,9 +1126,7 @@ void tpo_process_symbols(void)
     waypoint_temp = tpo_convert_ll(lat, lon);
 
     // Assign a generic waypoint name
-    xasprintf(&waypoint_name, "SYM %d", ii+1);
-//printf("Waypoint Name: %s\n", waypoint_name);
-    waypoint_temp->shortname = waypoint_name;
+    waypoint_temp->shortname = QString().sprintf("SYM %d", ii+1);
 
 //        waypoint_temp->description = NULL;
 //        waypoint_temp->notes = NULL;
@@ -1175,7 +1172,6 @@ void tpo_process_text_labels(void)
     int lat;
     int lon;
     unsigned int name_length;
-    char* waypoint_name;
     waypoint* waypoint_temp;
 
 
@@ -1192,9 +1188,7 @@ void tpo_process_text_labels(void)
     waypoint_temp = tpo_convert_ll(lat, lon);
 
     // Assign a generic waypoint name
-    xasprintf(&waypoint_name, "TXT %d", ii+1);
-//printf("Waypoint Name: %s\t\t", waypoint_name);
-    waypoint_temp->shortname = waypoint_name;
+    waypoint_temp->shortname = QString().sprintf("TXT %d", ii+1);
 
     for (jj = 0; jj < 16; jj++) {
 //UNKNOWN DATA LENGTH
@@ -1212,6 +1206,7 @@ void tpo_process_text_labels(void)
       gbfread(comment, 1, name_length, tpo_file_in);
       comment[name_length] = '\0';  // Terminator
       waypoint_temp->description = comment;
+      xfree(comment);
 //printf("Comment: %s\n", comment);
     } else {
 //            waypoint_temp->description = NULL;
@@ -1290,6 +1285,8 @@ void tpo_process_routes(void)
       xasprintf(&route_name, "RTE %d", ii+1);
     }
     route_temp->rte_name = route_name;
+    xfree(route_name);
+
 //printf("Route Name: %s\n", route_name);
 
 //UNKNOWN DATA LENGTH